package cn.nacos.system.shiro;

import cn.nacos.common.shiro.NacosRealm;
import cn.nacos.model.system.shiro.ProfileResult;
import org.apache.shiro.authc.*;

/**
 * @Author:ZhouYang
 * @Description:
 * @Date: Created in 2020/5/28 17:10
 * @Modified By： 模块下的realm
 */

public class UserRealm  extends NacosRealm {

    /**
     * 重写认证方法
     * @param authenticationToken
     * @return
     * @throws AuthenticationException
     */
    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
        //1.获取用户手机号码
        UsernamePasswordToken upToken = (UsernamePasswordToken) authenticationToken;
        //2.根据用户手机号码查询用户
//        User user = userDao.findByMobile(upToken.getUsername());
        //3.比对密码
        //构造安全数据
        ProfileResult result = ProfileResult.builder().username("root").company("123").build();
        return new SimpleAuthenticationInfo(result,"root",this.getName());
    }
}
